﻿<!DOCTYPE html>
<html>
<head>
    <title>ManageSystem</title>

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <link rel="stylesheet" href="/resource/loginCss/style.css" type="text/css" media="all">
    <link rel="stylesheet" type="text/css" href="/resource/js/jQueryMessage/css/message.skin.css" />
    <style>
        .sizeSmallImg{
            width: 25%;
            float: right;
            margin-top: 7px;
        }
    </style>
</head>
<body>
    <div class="banner">
        <div class="agileinfo-dot">


            <div class="w3layoutscontaineragileits">
                <h1>WelCome You</h1>
                <form method="post" id="loginForm">
                    <select id="newAddTargetDim" name="userRole"  onchange="changeNum(this.value)">
                        <option value="1" selected>教师</option>
                        <option value="2">学生</option>
                        <option value="3">系统管理员</option>
                    </select>
                    <input type="username" name="username" placeholder="NAME" required>
                    <input type="password" name="password" placeholder="密码" required>
                    <input  name ="check" type="check" id="verify_input" placeholder="请输入验证码" maxlength="4">
                    <a href="javascript:void(0);"  title="点击更换验证码">
                        <img class="sizeSmallImg" id="imgVerify" src="" alt="更换验证码" height="36" width="100%" onclick="getVerify(this);">
                    </a>
                    <ul class="agileinfotickwthree">
                        <li>
                            <input type="checkbox" id="brand1" value="">
                            <label for="brand1"><span></span>记住密码</label>
                            <a href="#">忘记密码?</a>
                        </li>
                    </ul>
                    <div class="aitssendbuttonw3ls electRole">
                        <input type="button" onclick="login();" value="登录">
                        <div class="clear"></div>
                    </div>
                </form>
            </div>


            <div class="w3footeragile">
                <p> &copy; Copyright © 2020 I Tech You,我教你  京ICP备6666666号 | Dougls by <a href="http://www.llnh1314.xyz">bootstrapmb</a></p>
            </div>

        </div>
    </div>



    <script type="text/javascript" src="/resource/js/jquery.min.js"></script>
    <script type="text/javascript" src="/resource/js/jQueryMessage/js/jquery.plugin.message.js"></script>
    <script type="text/javascript" src="/resource/js/vector.js"></script>
    <script type="text/javascript">
        if (window.frames.length != parent.frames.length) {
            window.parent.location.href = "/admin/user/logout";
        }

        //刷新验证码
        window.onload=function(){
            obj.src = "http://localhost:8866/admin/getVerify?"+Math.random();
        }
        //填充验证码
        $(function () {
            document.getElementById("imgVerify").click();
        });

        //获取验证码
        function getVerify(obj){
            obj.src = "http://localhost:8866/admin/getVerify?"+Math.random();
        }

        //登录请求
        function login(){
            var username = $('input[name="username"]').val();
            var password = $('input[name="password"]').val();
            var userRole = $('select[name="userRole"]').val();
            var check = $('input[name="check"]').val();
            console.log(userRole)
            var data = {
                username : username,
                password : password,
                userRole : userRole,
                check : check,
                rememberMe : false
            };

            $.ajax({
                url : "/admin/user/login",
                contentType : 'application/json',
                data : JSON.stringify(data),
                type : "POST",
                dataType : "JSON",
                success : function(result) {
                    console.log(result);
                    if(result.success){
                        sessionStorage.setItem("douglas", JSON.stringify(result.data));
                        $("body").MessageBox({
                            type: 'success',
                            message:result.info,
                            timeout:3000,
                            callbak:null
                        });
                        //登录成功跳转页面的请求
                        setTimeout(function() {
                            //登录返回
                            window.location.href = "/admin/user/toIndex";
                        }, 500);
                    }else{
                        $("body").MessageBox({
                            type: 'error',
                            message:result.info,
                            timeout:3000,
                            callbak:null
                        });
                    }
                }
            });
        }
    </script>
</body>
<!-- //Body -->

</html>
